<!DOCTYPE html>
<html>
<head>
    <title>添加测试数据</title>
    <meta charset="utf-8">
    <script src="js/jquery.js"></script>
</head>
<body>
    <h2>添加测试数据</h2>
    <form id="dataForm">
        <div>
            <label>昵称:</label>
            <input type="text" id="nickname" name="nickname" required>
        </div>
        <div>
            <label>分数:</label>
            <input type="number" id="score" name="score" required>
        </div>
        <div>
            <label>时间:</label>
            <input type="number" id="time" name="time" required>
        </div>
        <button type="button" id="submitBtn">提交</button>
    </form>
    <div id="result"></div>

    <script>
        $(document).ready(function() {
            $('#submitBtn').click(function() {
                const data = {
                    nickname: $('#nickname').val(),
                    score: parseInt($('#score').val()),
                    time: parseInt($('#time').val())
                };

                $.ajax({
                    url: 'php/rank.php',
                    type: 'POST',
                    contentType: 'application/json',
                    data: JSON.stringify(data),
                    success: function(response) {
                        $('#result').html('提交成功: ' + JSON.stringify(response));
                    },
                    error: function(xhr, status, error) {
                        $('#result').html('提交失败: ' + error);
                    }
                });
            });
        });
    </script>
</body>
</html>